package com.sc.nft.entity.vo.metaWalletDTO.request;

import cn.hutool.crypto.SecureUtil;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class CrossTransferReceiveRequest {

  @NotBlank(message = "handleId不能为空")
  private String handleId;

  @NotBlank(message = "tokenId不能为空")
  private String tokenId;

  @NotBlank(message = "collectionId不能为空")
  private String collectionId;

  @NotBlank(message = "fromUserAddress地址不能为空")
  private String fromUserAddress;

  @NotBlank(message = "toUserAddress地址不能为空")
  private String toUserAddress;


  public void aesEncode(String key) {
    this.setHandleId(SecureUtil.aes(key.getBytes()).encryptHex(this.handleId));
    this.setTokenId(SecureUtil.aes(key.getBytes()).encryptHex(this.tokenId));
    this.setFromUserAddress(SecureUtil.aes(key.getBytes()).encryptHex(this.fromUserAddress));
    this.setToUserAddress(SecureUtil.aes(key.getBytes()).encryptHex(this.toUserAddress));
  }

  public void aesDecode(String key) {
    this.setHandleId(SecureUtil.aes(key.getBytes()).decryptStr(this.handleId));
    this.setTokenId(SecureUtil.aes(key.getBytes()).decryptStr(this.tokenId));
    this.setFromUserAddress(SecureUtil.aes(key.getBytes()).decryptStr(this.fromUserAddress));
    this.setToUserAddress(SecureUtil.aes(key.getBytes()).decryptStr(this.toUserAddress));
  }
}
